TOP = $(shell pwd)

DIRS = winap

GCORE = faky
OBJS = lib/misc.o lib/unicode.o
CROSS =

export GCORE

include $(TOP)/config
include $(TOP)/arch.make

ifeq ($(GPU_SUPPORT), y)
OBJS    += drivers/graphic/gpu.o \
           drivers/graphic/glt.o \
           drivers/graphic/videoin.o
endif

ifeq ($(AUDIO_SUPPORT), y)
ifeq ($(BUZZER_SUPPORT), y)
OBJS    += drivers/sound/buzzer.o
endif
endif

ifeq ($(INPUT_DEVICE_SUPPORT), y)
OBJS    += drivers/input/input.o
ifeq ($(YUN_TOUCH_SCREEN_SUPPORT), y)
OBJS    += drivers/input/touch_yun.o
endif
endif

ifeq ($(BLUETOOTH_SUPPORT), y)
OBJS    += drivers/bluetooth/btcore.o

ifeq ($(BT_HSM30_SUPPORT), y)
OBJS    += drivers/bluetooth/hsm30.o
endif
endif

ifeq ($(BMP_SUPPORT), y)
OBJS    += lib/image_bmp.o
endif


ifeq ($(JPEG_SUPPORT), y)
OBJS    += lib/image_jpeg.o
endif


ifeq ($(FONT_SUPPORT), y)
ifeq ($(FONT_BDF_SUPPORT), y)
OBJS    += lib/font_bdf.o
endif

ifeq ($(FONT_FREETYPE2_SUPPORT), y)
OBJS    += lib/font_freetype2.o
endif

OBJS    += core/font.o
endif


OBJS += core/system.o          \
        core/gapi.o            \
        core/page.o            \
        core/image.o           \
        core/gobjs.o           \
        core/event.o           \
        core/color.o           \
        core/main.o

all: lib $(GCORE)

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

$(GCORE):
	for i in $(DIRS) ; do $(MAKE) -C $$i $? || exit ; done
	@echo "###############################"
	@echo "#          Complete!          #"
	@echo "###############################"

lib: $(OBJS)
	$(AR) r lib$(GCORE).a $(OBJS)

clean:
	$(RM) $(OBJS) lib$(GCORE).a *.gdb *.bflt *.elf *.elf2flt
	for i in $(DIRS) ; do $(MAKE) -C $$i clean || exit ; done

